﻿using ConsoleApp1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("------欢迎进入游戏世界------");
            Console.WriteLine();
            Console.WriteLine("****************************");
            Console.WriteLine("*********猜拳，开始*********");
            Console.WriteLine("****************************");
            Console.WriteLine("出拳规则：1.剪刀 2.石头 3.布");

            Console.WriteLine("请选择对方角色（1：刘备 2：孙权 3：曹操）");
            int Key = int.Parse(Console.ReadLine());
            Console.Write("请输入您的姓名：");
            string userName = Console.ReadLine();
            string npcName = null;
            switch (Key)
            {
                case 1:
                    npcName = "刘备";
                    Go(userName, npcName);

                    break;
                case 2:
                    npcName = "孙权";
                    Go(userName, npcName);
                    break;
                case 3:
                    npcName = "曹操";
                    Go(userName, npcName);
                    break;
                default:
                    break;
            }
        }

        private static void Go(string a, string b)
        {
            Npc nPC = new Npc(a, b);
            Player user = new Player(a, b);

            Console.WriteLine($"{user.name} VS {nPC.name1} 对战");
            Console.WriteLine("开始游戏吗（y/n）");
            char key = char.Parse(Console.ReadLine());
            if (key == ('y' | 'Y'))
            {
                user.talk1();
                nPC.talk1();
                int f = (int)user.Guess();
                int i = (int)nPC.Guess();
                
                NextRound(nPC,user);
            }
            else if (key == ('n' | 'N'))
            {
                
                Environment.Exit(0);
                NextRound(nPC, user);

            }
            else
            {
                Console.WriteLine("选择出错！自动退出");
                Environment.Exit(0);
            }

        }


        public static void NextRound(Npc nPC, Player user)
        {
            Referee referee = new Referee();
            Console.WriteLine("是否开始下一轮（y/n）");
            char key = char.Parse(Console.ReadLine());
            if (key == ('y' | 'Y'))
            {
                user.talk1();
                nPC.talk1();
                NextRound(nPC, user);
            }
            else if (key == ('n' | 'N'))
            {
                referee.Date1();
            }


        }
    }
}
